import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MiniProgramBaseInfoVO, MiniProgramBaseInfoForm, MiniProgramBaseInfoQuery } from '@/api/platform/miniProgramBaseInfo/types';

/**
 * 查询小程序基础信息列表
 * @param query
 * @returns {*}
 */

export const listMiniProgramBaseInfo = (query?: MiniProgramBaseInfoQuery): AxiosPromise<MiniProgramBaseInfoVO[]> => {
  return request({
    url: '/platform/miniProgramBaseInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小程序基础信息详细
 * @param id
 */
export const getMiniProgramBaseInfo = (id: string | number): AxiosPromise<MiniProgramBaseInfoVO> => {
  return request({
    url: '/platform/miniProgramBaseInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增小程序基础信息
 * @param data
 */
export const addMiniProgramBaseInfo = (data: MiniProgramBaseInfoForm) => {
  return request({
    url: '/platform/miniProgramBaseInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改小程序基础信息
 * @param data
 */
export const updateMiniProgramBaseInfo = (data: MiniProgramBaseInfoForm) => {
  return request({
    url: '/platform/miniProgramBaseInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除小程序基础信息
 * @param id
 */
export const delMiniProgramBaseInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/platform/miniProgramBaseInfo/' + id,
    method: 'delete'
  });
};

/**
 * 下拉框查询企业下小程序
 * @param query
 * @returns
 */
export const getAppName = (query?: MiniProgramBaseInfoQuery): AxiosPromise<MiniProgramBaseInfoVO[]> => {
  return request({
    url: '/platform/miniProgramBaseInfo/getAppName',
    method: 'get',
    params: query
  });
};

/**
 * app详情
 * @param query
 * @returns
 */
export const getAppDetails = (query?: MiniProgramBaseInfoQuery): AxiosPromise<MiniProgramBaseInfoVO[]> => {
  return request({
    url: '/platform/miniProgramBaseInfo/getAppDetails',
    method: 'get',
    params: query
  });
};


/**
 * 修改小程序名称
 * @param data
 */
export const updateNickName = (data: MiniProgramBaseInfoForm) => {
  return request({
    url: '/platform/miniProgramBaseInfo/setNickName',
    method: 'post',
    data: data
  });
};


/**
 * 修改小程序简介
 * @param data
 */
export const updateSignature = (data: MiniProgramBaseInfoForm) => {
  return request({
    url: '/platform/miniProgramBaseInfo/setSignature',
    method: 'post',
    data: data
  });
};